home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MOR55SRC.ZIP / MORIA / SOURCE / TYPES.H < prev    next >
Text File  |  1992-12-07  |  13KB  |  391 lines

  1. /* source/types.h: global type declarations
  2.  
  3.    Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  4.  
  5.    This software may be copied and distributed for educational, research, and
  6.    not for profit purposes provided that this copyright and statement are
  7.    included in all such copies. */
  8.  
  9. typedef unsigned long  int32u;
  10. typedef long           int32;
  11. typedef unsigned short int16u;
  12. typedef short           int16;
  13. typedef unsigned char  int8u;
  14. /* some machines will not accept 'signed char' as a type, and some accept it
  15.    but still treat it like an unsigned character, let's just avoid it,
  16.    any variable which can ever hold a negative value must be 16 or 32 bits */
  17.  
  18. #define VTYPESIZ    80
  19. #define BIGVTYPESIZ    160
  20. typedef char vtype[VTYPESIZ];
  21. /* note that since its output can easily exceed 80 characters, objdes must
  22.    always be called with a bigvtype as the first paramter */
  23. typedef char bigvtype[BIGVTYPESIZ];
  24. typedef char stat_type[7];
  25.  
  26. /* Many of the character fields used to be fixed length, which greatly
  27.    increased the size of the executable.  I have replaced many fixed
  28.    length fields with variable length ones. */
  29.  
  30. /* all fields are given the smallest possbile type, and all fields are
  31.    aligned within the structure to their natural size boundary, so that
  32.    the structures contain no padding and are minimum size */
  33.  
  34. /* bit fields are only used where they would cause a large reduction in
  35.    data size, they should not be used otherwise because their use
  36.    results in larger and slower code */
  37.  
  38. typedef struct creature_type
  39. {
  40.   char *name;        /* Descrip of creature    */
  41.   int32u cmove;        /* Bit field        */
  42.   int32u spells;    /* Creature spells    */
  43.   int16u cdefense;    /* Bit field        */
  44.   int16u mexp;        /* Exp value for kill    */
  45.   int8u sleep;        /* Inactive counter/10    */
  46.   int8u aaf;        /* Area affect radius    */
  47.   int8u ac;        /* AC            */
  48.   int8u speed;        /* Movement speed+10    */
  49.   int8u cchar;        /* Character rep.    */
  50.   int8u hd[2];        /* Creatures hit die    */
  51.   int8u damage[4];    /* Type attack and damage*/
  52.   int8u level;        /* Level of creature    */
  53. } creature_type;
  54.  
  55. typedef struct m_attack_type    /* Monster attack and damage types */
  56.   {
  57.     int8u attack_type;
  58.     int8u attack_desc;
  59.     int8u attack_dice;
  60.     int8u attack_sides;
  61.   } m_attack_type;
  62.  
  63. typedef struct recall_type    /* Monster memories. -CJS- */
  64.   {
  65.     int32u r_cmove;
  66.     int32u r_spells;
  67.     int16u r_kills, r_deaths;
  68.     int16u r_cdefense;
  69.     int8u r_wake, r_ignore;
  70.     int8u r_attacks[MAX_MON_NATTACK];
  71.   } recall_type;
  72.  
  73. typedef struct monster_type
  74. {
  75.   int16 hp;        /* Hit points        */
  76.   int16 csleep;        /* Inactive counter    */
  77.   int16 cspeed;        /* Movement speed    */
  78.   int16u mptr;        /* Pointer into creature*/
  79.   /* Note: fy, fx, and cdis constrain dungeon size to less than 256 by 256 */
  80.   int8u fy;        /* Y Pointer into map    */
  81.   int8u fx;        /* X Pointer into map    */
  82.   int8u cdis;        /* Cur dis from player    */
  83.   int8u ml;
  84.   int8u stunned;
  85.   int8u confused;
  86. } monster_type;
  87.  
  88. typedef struct treasure_type
  89. {
  90.   char *name;        /* Object name        */
  91.   int32u flags;        /* Special flags    */
  92.   int8u tval;        /* Category number    */
  93.   int8u tchar;        /* Character representation*/
  94.   int16 p1;        /* Misc. use variable    */
  95.   int32 cost;        /* Cost of item        */
  96.   int8u subval;        /* Sub-category number    */
  97.   int8u number;        /* Number of items    */
  98.   int16u weight;    /* Weight        */
  99.   int16 tohit;        /* Plusses to hit    */
  100.   int16 todam;        /* Plusses to damage    */
  101.   int16 ac;        /* Normal AC        */
  102.   int16 toac;        /* Plusses to AC    */
  103.   int8u damage[2];    /* Damage when hits    */
  104.   int8u level;        /* Level item first found */
  105. } treasure_type;
  106.  
  107. /* only damage, ac, and tchar are constant; level could possibly be made
  108.    constant by changing index instead; all are used rarely */
  109. /* extra fields x and y for location in dungeon would simplify pusht() */
  110. /* making inscrip a pointer and mallocing space does not work, there are
  111.    two many places where inven_types are copied, which results in dangling
  112.    pointers, so we use a char array for them instead */
  113. #define INSCRIP_SIZE 13  /* notice alignment, must be 4*x + 1 */
  114. typedef struct inven_type
  115. {
  116.   int16u index;        /* Index to object_list */
  117.   int8u name2;        /* Object special name  */
  118.   char inscrip[INSCRIP_SIZE]; /* Object inscription   */
  119.   int32u flags;        /* Special flags    */
  120.   int8u tval;        /* Category number    */
  121.   int8u tchar;        /* Character representation*/
  122.   int16 p1;        /* Misc. use variable    */
  123.   int32 cost;        /* Cost of item        */
  124.   int8u subval;        /* Sub-category number    */
  125.   int8u number;        /* Number of items    */
  126.   int16u weight;    /* Weight        */
  127.   int16 tohit;        /* Plusses to hit    */
  128.   int16 todam;        /* Plusses to damage    */
  129.   int16 ac;        /* Normal AC        */
  130.   int16 toac;        /* Plusses to AC    */
  131.   int8u damage[2];    /* Damage when hits    */
  132.   int8u level;        /* Level item first found */
  133.   int8u ident;        /* Identify information */
  134. } inven_type;
  135.  
  136. #define PLAYER_NAME_SIZE 27
  137.  
  138. typedef struct player_type
  139. {
  140.   struct misc
  141.     {
  142.       char name[PLAYER_NAME_SIZE];    /* Name of character    */
  143.       int8u male;    /* Sex of character    */
  144.       int32 au;        /* Gold            */
  145.       int32 max_exp;    /* Max experience    */
  146.       int32 exp;    /* Cur experience    */
  147.       int16u exp_frac;    /* Cur exp fraction * 2^16 */
  148.       int16u age;    /* Characters age    */
  149.       int16u ht;    /* Height        */
  150.       int16u wt;    /* Weight        */
  151.       int16u lev;    /* Level        */
  152.       int16u max_dlv;    /* Max level explored    */
  153.       int16 srh;    /* Chance in search    */
  154.       int16 fos;    /* Frenq of search    */
  155.       int16 bth;    /* Base to hit        */
  156.       int16 bthb;    /* BTH with bows    */
  157.       int16 mana;    /* Mana points        */
  158.       int16 mhp;    /* Max hit pts        */
  159.       int16 ptohit;    /* Plusses to hit    */
  160.       int16 ptodam;    /* Plusses to dam    */
  161.       int16 pac;    /* Total AC        */
  162.       int16 ptoac;    /* Magical AC        */
  163.       int16 dis_th;    /* Display +ToHit    */
  164.       int16 dis_td;    /* Display +ToDam    */
  165.       int16 dis_ac;    /* Display +ToAC    */
  166.       int16 dis_tac;    /* Display +ToTAC    */
  167.       int16 disarm;    /* % to Disarm        */
  168.       int16 save;    /* Saving throw        */
  169.       int16 sc;        /* Social Class        */
  170.       int16 stl;    /* Stealth factor    */
  171.       int8u pclass;    /* # of class        */
  172.       int8u prace;    /* # of race        */
  173.       int8u hitdie;    /* Char hit die        */
  174.       int8u expfact;    /* Experience factor    */
  175.       int16 cmana;    /* Cur mana pts        */
  176.       int16u cmana_frac; /* Cur mana fraction * 2^16 */
  177.       int16 chp;    /* Cur hit pts        */
  178.       int16u chp_frac;    /* Cur hit fraction * 2^16 */
  179.       char history[4][60]; /* History record    */
  180.     } misc;
  181.   /* Stats now kept in arrays, for more efficient access. -CJS- */
  182.   struct stats
  183.     {
  184.       int8u max_stat[6];    /* What is restored */
  185.       int8u cur_stat[6];    /* What is natural */
  186.       int16 mod_stat[6];    /* What is modified, may be +/- */
  187.       int8u use_stat[6];    /* What is used */
  188.     } stats;
  189.   struct flags
  190.     {
  191.       int32u status;        /* Status of player    */
  192.       int16 rest;        /* Rest counter           */
  193.       int16 blind;        /* Blindness counter   */
  194.       int16 paralysis;        /* Paralysis counter   */
  195.       int16 confused;        /* Confusion counter   */
  196.       int16 food;        /* Food counter           */
  197.       int16 food_digested;    /* Food per round      */
  198.       int16 protection;        /* Protection fr. evil */
  199.       int16 speed;        /* Cur speed adjust    */
  200.       int16 fast;        /* Temp speed change   */
  201.       int16 slow;        /* Temp speed change   */
  202.       int16 afraid;        /* Fear               */
  203.       int16 poisoned;        /* Poisoned           */
  204.       int16 image;        /* Hallucinate           */
  205.       int16 protevil;        /* Protect VS evil     */
  206.       int16 invuln;        /* Increases AC           */
  207.       int16 hero;        /* Heroism           */
  208.       int16 shero;        /* Super Heroism       */
  209.       int16 blessed;        /* Blessed           */
  210.       int16 resist_heat;    /* Timed heat resist   */
  211.       int16 resist_cold;    /* Timed cold resist   */
  212.       int16 detect_inv;        /* Timed see invisible */
  213.       int16 word_recall;    /* Timed teleport level*/
  214.       int16 see_infra;        /* See warm creatures  */
  215.       int16 tim_infra;        /* Timed infra vision  */
  216.       int8u see_inv;        /* Can see invisible   */
  217.       int8u teleport;        /* Random teleportation*/
  218.       int8u free_act;        /* Never paralyzed     */
  219.       int8u slow_digest;    /* Lower food needs    */
  220.       int8u aggravate;        /* Aggravate monsters  */
  221.       int8u fire_resist;    /* Resistance to fire  */
  222.       int8u cold_resist;    /* Resistance to cold  */
  223.       int8u acid_resist;    /* Resistance to acid  */
  224.       int8u regenerate;        /* Regenerate hit pts  */
  225.       int8u lght_resist;    /* Resistance to light */
  226.       int8u ffall;        /* No damage falling   */
  227.       int8u sustain_str;    /* Keep strength       */
  228.       int8u sustain_int;    /* Keep intelligence   */
  229.       int8u sustain_wis;    /* Keep wisdom           */
  230.       int8u sustain_con;    /* Keep constitution   */
  231.       int8u sustain_dex;    /* Keep dexterity      */
  232.       int8u sustain_chr;    /* Keep charisma       */
  233.       int8u confuse_monster;    /* Glowing hands.    */
  234.       int8u new_spells;        /* Number of spells can learn. */
  235.     } flags;
  236. } player_type;
  237.  
  238. typedef struct spell_type
  239. {  /* spell name is stored in spell_names[] array at index i, +31 if priest */
  240.   int8u slevel;
  241.   int8u smana;
  242.   int8u sfail;
  243.   int8u sexp;    /* 1/4 of exp gained for learning spell */
  244. } spell_type;
  245.  
  246. typedef struct race_type
  247. {
  248.   char    *trace;        /* Type of race            */
  249.   int16 str_adj;    /* adjustments            */
  250.   int16 int_adj;
  251.   int16 wis_adj;
  252.   int16 dex_adj;
  253.   int16 con_adj;
  254.   int16 chr_adj;
  255.   int8u b_age;           /* Base age of character        */
  256.   int8u m_age;           /* Maximum age of character    */
  257.   int8u m_b_ht;          /* base height for males        */
  258.   int8u m_m_ht;          /* mod height for males        */
  259.   int8u m_b_wt;          /* base weight for males        */
  260.   int8u m_m_wt;          /* mod weight for males        */
  261.   int8u f_b_ht;          /* base height females        */
  262.   int8u f_m_ht;          /* mod height for females    */
  263.   int8u f_b_wt;          /* base weight for female    */
  264.   int8u f_m_wt;          /* mod weight for females    */
  265.   int16 b_dis;           /* base chance to disarm        */
  266.   int16 srh;           /* base chance for search    */
  267.   int16 stl;           /* Stealth of character        */
  268.   int16 fos;           /* frequency of auto search    */
  269.   int16 bth;           /* adj base chance to hit    */
  270.   int16 bthb;           /* adj base to hit with bows    */
  271.   int16 bsav;           /* Race base for saving throw    */
  272.   int8u bhitdie;           /* Base hit points for race    */
  273.   int8u infra;           /* See infra-red            */
  274.   int8u b_exp;           /* Base experience factor    */
  275.   int8u rtclass;       /* Bit field for class types    */
  276. } race_type;
  277.  
  278. typedef struct class_type
  279. {
  280.   char *title;        /* type of class        */
  281.   int8u adj_hd;        /* Adjust hit points        */
  282.   int8u mdis;        /* mod disarming traps        */
  283.   int8u msrh;        /* modifier to searching    */
  284.   int8u mstl;        /* modifier to stealth        */
  285.   int8u mfos;        /* modifier to freq-of-search    */
  286.   int8u mbth;        /* modifier to base to hit    */
  287.   int8u mbthb;        /* modifier to base to hit - bows*/
  288.   int8u msav;        /* Class modifier to save    */
  289.   int16 madj_str;    /* Class modifier for strength    */
  290.   int16 madj_int;    /* Class modifier for intelligence*/
  291.   int16 madj_wis;    /* Class modifier for wisdom    */
  292.   int16 madj_dex;    /* Class modifier for dexterity */
  293.   int16 madj_con;    /* Class modifier for constitution*/
  294.   int16 madj_chr;    /* Class modifier for charisma    */
  295.   int8u spell;        /* class use mage spells    */
  296.   int8u m_exp;        /* Class experience factor    */
  297.   int8u first_spell_lev;/* First level where class can use spells. */
  298. } class_type;
  299.  
  300. typedef struct background_type
  301. {
  302.   char *info;        /* History information        */
  303.   int8u roll;        /* Die roll needed for history    */
  304.   int8u chart;        /* Table number            */
  305.   int8u next;        /* Pointer to next table    */
  306.   int8u bonus;        /* Bonus to the Social Class+50    */
  307. } background_type;
  308.  
  309. typedef struct cave_type
  310. {
  311. #ifdef AMIGA
  312.   /* This reduces the size from 64 bits to 32 bits. */
  313.   unsigned int cptr : 8;
  314.   unsigned int tptr : 8;
  315.   unsigned int fval : 8;
  316. #else
  317.   int8u cptr;
  318.   int8u tptr;
  319.   int8u fval;
  320. #endif
  321. #if !defined(MSDOS) && !defined(ATARIST_MWC)
  322.   unsigned int lr : 1;  /* room should be lit with perm light, walls with
  323.                this set should be perm lit after tunneled out */
  324.   unsigned int fm : 1;    /* field mark, used for traps/doors/stairs, object is
  325.                hidden if fm is FALSE */
  326.   unsigned int pl : 1;    /* permanent light, used for walls and lighted rooms */
  327.   unsigned int tl : 1;    /* temporary light, used for player's lamp light,etc.*/
  328. #else
  329. #ifndef __TURBOC__
  330.   /* this is not legal ANSI C, this is a MSC extension, which will use 1 byte
  331.      for the bitfields whereas MSC uses 2 bytes for the bitfields above */
  332.   /* this is also a MWC extension on the Atari ST */
  333.   unsigned char lr : 1;
  334.   unsigned char fm : 1;
  335.   unsigned char pl : 1;
  336.   unsigned char tl : 1;
  337. #else
  338.   unsigned lr : 1;
  339.   unsigned fm : 1;
  340.   unsigned pl : 1;
  341.   unsigned tl : 1;
  342. #endif
  343. #endif
  344. } cave_type;
  345.  
  346. typedef struct owner_type
  347. {
  348.   char *owner_name;
  349.   int16 max_cost;
  350.   int8u max_inflate;
  351.   int8u min_inflate;
  352.   int8u haggle_per;
  353.   int8u owner_race;
  354.   int8u insult_max;
  355. } owner_type;
  356.  
  357. typedef struct inven_record
  358. {
  359.   int32 scost;
  360.   inven_type sitem;
  361. } inven_record;
  362.  
  363. typedef struct store_type
  364. {
  365.   int32 store_open;
  366.   int16 insult_cur;
  367.   int8u owner;
  368.   int8u store_ctr;
  369.   int16u good_buy;
  370.   int16u bad_buy;
  371.   inven_record store_inven[STORE_INVEN_MAX];
  372. } store_type;
  373.  
  374. /* 64 bytes for this structure */
  375. typedef struct high_scores
  376. {
  377.   int32 points;
  378.   int32 birth_date;
  379.   int16 uid;
  380.   int16 mhp;
  381.   int16 chp;
  382.   int8u dun_level;
  383.   int8u lev;
  384.   int8u max_dlv;
  385.   int8u sex;
  386.   int8u race;
  387.   int8u class;
  388.   char name[PLAYER_NAME_SIZE];
  389.   char died_from[25];
  390. } high_scores;
  391.